package com.zyk.leetcode;

/**
 * @author zhangsan
 * @date 2021/4/4 22:48
 */
public class J42 {

    public static int maxSubArray(int[] nums) {

        int res = nums[0];
        for(int i = 1; i < nums.length; i++) {
            nums[i] += Math.max(nums[i - 1], 0);
            res = Math.max(res, nums[i]);
        }
        return res;
    }

    // for test
    public static void main(String[] args) {

    }

}
